#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_timeit_decorator.py
# author:张世航
# datetime:2024/11/10 17:00
# software: PyCharm
"""
this is function  description 
"""
# import module your need

# 1  编写一个装饰器，能计算其他函数的运行时间；
#
import time

def timeit_decorator(func):
    def wrapper(*args, **kwargs):
        start_time = time.time()
        result = func(*args, **kwargs)
        end_time = time.time()
        print(f"Function {func.__name__} took {end_time - start_time:.4f} seconds")
        return result
    return wrapper

# 示例
@timeit_decorator
def example_function():
    # 模拟一些计算
    time.sleep(2)

example_function()